import { IPSAppDEField } from '../../app/dataentity/ipsapp-defield';
import { IPSDEListDataItem } from './ipsdelist-data-item';
import { PSListDataItemImpl } from './pslist-data-item-impl';

export class PSDEListDataItemImpl extends PSListDataItemImpl implements IPSDEListDataItem {
  protected psappdefield: IPSAppDEField | null = null;

  getPSAppDEField(): IPSAppDEField | null {
    if (this.psappdefield != null) return this.psappdefield;
    const value = this.M.getPSAppDEField;
    if (value == null) {
      return null;
    }
    this.psappdefield = this.getPSModel4('app.dataentity.IPSAppDEField', value, 'getPSAppDEField') as IPSAppDEField;
    return this.psappdefield;
  }

  get psAppDEField(): IPSAppDEField | null {
    return this.getPSAppDEField();
  }

  getPSAppDEFieldMust(): IPSAppDEField {
    const value = this.getPSAppDEField();
    if (value == null) {
      throw new Error('未指定关联应用实体属性');
    }
    return value;
  }

  get cls(): string {
    return 'PSDEListDataItemImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.list.IPSDEListDataItem') return true;
    return super.instanceof(cls);
  }
}
